﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MainTemplate.Master" AutoEventWireup="true" CodeBehind="ProjectCase.aspx.cs" Inherits="Enterprise.Admin.ProjectCase" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="../Content/Widget/kindeditor/plugins/code/prettify.css" rel="stylesheet" />
    <link href="../Content/Widget/fancyBox/jquery.fancybox.css" rel="stylesheet" />
    <script src="../Content/Widget/fancyBox/jquery.fancybox.pack.js" type="text/javascript" charset="utf-8"></script>
    <script src="../Content/Widget/fancyBox/jquery.mousewheel.pack.js" type="text/javascript" charset="utf-8"></script>
    <script src="../Content/Widget/fancyBox/jquery.easing.pack.js" type="text/javascript" charset="utf-8"></script>
    <script src="../Content/Widget/AjaxFileUploader/ajaxfileupload.js" charset="utf-8" type="text/javascript"></script>
    <script src="../Content/Widget/kindeditor/kindeditor-min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../Content/Widget/kindeditor/lang/zh_CN.js" type="text/javascript" charset="utf-8"></script>
    <script src="../Content/Widget/kindeditor/plugins/code/prettify.js" type="text/javascript" charset="utf-8"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table id="table_list"></table>
    <div id="search">
        <form id="search_form" action="Handle/Project/GetListJson.aspx" method="get">
            <p>
                <label>名称：</label><input type="text" name="CoName" />
            </p>
        </form>
    </div>
    <div id="add">
        <form id="add_form" action="Handle/Project/Add.aspx" method="post">
            <div id="add_tabs" style="padding: 0px; height: auto">
                <div title="基础资料">
                    <p>
                        <label>名称：</label><input type="text" name="CoName" value="" />
                    </p>
                    <p class="en-us">
                        <label>名称(En)：</label><input type="text" name="CoNameEn" value="" />
                    </p>
                    <p>
                        <label>文件：</label><span id="add_upload_box"><input type="file" id="add_upload" name="Filedata" /></span>
                    </p>
                    <p>
                        <label>排序：</label><input type="text" name="CoSort" value="" />
                    </p>
                </div>
                <div title="内容">
                    <textarea id="add_content" name="CoContent"></textarea>
                </div>
                <div title="内容(En)">
                    <textarea id="add_content_en" name="CoContentEn"></textarea>
                </div>
            </div>
        </form>
    </div>
    <div id="edit">
        <form id="edit_form" action="Handle/Project/Edit.aspx" method="post">
            <div id="edit_tabs" style="padding: 0px; height: auto">
                <div title="基础资料">
                    <p>
                        <label>名称：</label><input type="text" name="CoName" value="" />
                        <input id="edit_id" name="CoProjectId" type="hidden" value="" />
                    </p>
                    <p class="en-us">
                        <label>名称(En)：</label><input type="text" name="CoNameEn" value="" />
                    </p>
                    <p>
                        <label>文件：</label><span id="edit_upload_box"><input type="file" id="edit_upload" name="Filedata" /></span>
                    </p>
                    <p>
                        <label>排序：</label><input type="text" name="CoSort" value="" />
                    </p>

                </div>
                <div title="内容">
                    <textarea id="edit_content" name="CoContent"></textarea>
                </div>
                <div title="内容(En)">
                    <textarea id="edit_content_en" name="CoContentEn"></textarea>
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            var tableList = $("#table_list").datagrid({
                title: '项目案例列表',
                url: 'Handle/Project/GetListJson.aspx',
                onLoadSuccess: function () {
                    $(".fancybox_image").fancybox({
                        'transitionIn': 'none',
                        'transitionOut': 'none',
                        'titlePosition': 'over'
                    });
                },
                columns: [[
                    { title: 'Id', field: 'id', width: 280, align: 'center', checkbox: true },
                    { title: '名称', field: 'CoName', width: 280, align: 'center' },
                    { title: '排序', field: 'CoSort', width: 100, align: 'center' },
                    {
                        field: 'CoNormalImage',
                        title: '图片',
                        width: 80,
                        align: 'center',
                        formatter: function (value, rowData) {
                            return '<a class="fancybox_image" href="../upload/Project/' + rowData.CoNormalImage + '"></a>';
                        }
                    },
                    {
                        title: '修改',
                        field: 'OpEdit',
                        width: 80,
                        align: 'center',
                        formatter: function (value, rec) {
                            return '<a href="javascript:void(0);" mce_href="#" onclick="edit(\'' + rec.id + '\')">修改</a> ';
                        }
                    },
                    {
                        title: '删除',
                        field: 'OpDelete',
                        width: 80,
                        align: 'center',
                        formatter: function (value, rec) {
                            return '<a href="javascript:void(0);" mce_href="#" onclick="del(\'' + rec.id + '\')">删除</a> ';
                        }
                    }
                ]]
            });
            $('#edit').dialog({
                title: '修改项目案例',
                width: 750,
                height: 500,
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {
                        editContent.sync();
                        editContentEn.sync();
                        editSave();
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#edit').dialog('close');
                    }
                }]
            });
            $('#search').dialog({
                title: '检索项目案例',
                width: 400,
                buttons: [{
                    text: '查找',
                    iconCls: 'icon-ok',
                    handler: function () {
                        tableList.datagrid("reload", $('#search_form').serializeObject());
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#search').dialog('close');
                    }
                }]
            });
            $('#add').dialog({
                title: '添加项目案例',
                width: 750,
                height: 500,
                closed: true,
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {
                        addContent.sync();
                        addContentEn.sync();
                        addSave();

                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#add_team_style').dialog('close');
                    }
                }]

            });
            $('#edit_form').form({
                onLoadSuccess: function (data) {
                    editContent.html(data.CoContent);
                    editContentEn.html(data.CoContentEn);
                    $('#edit').dialog("open");
                }
            });
            $('#add_tabs').tabs();
            $('#edit_tabs').tabs();
            var addContent = window.KindEditor.create('#add_content', {
                uploadJson: "Handle/KindEditorUploadJson.aspx",
                fileManagerJson: "Handle/KindEditorFileManagerJson.aspx",
                width: '668px',
                height: '375px',
                filterMode: false,
                allowFileManager: true
            });
            var addContentEn = window.KindEditor.create('#add_content_en', {
                uploadJson: "Handle/KindEditorUploadJson.aspx",
                fileManagerJson: "Handle/KindEditorFileManagerJson.aspx",
                width: '668px',
                height: '375px',
                filterMode: false,
                allowFileManager: true
            });
            var editContent = window.KindEditor.create('#edit_content', {
                uploadJson: "Handle/KindEditorUploadJson.aspx",
                fileManagerJson: "Handle/KindEditorFileManagerJson.aspx",
                width: '668px',
                height: '375px',
                filterMode: false,
                allowFileManager: true

            });
            var editContentEn = window.KindEditor.create('#edit_content_en', {
                uploadJson: "Handle/KindEditorUploadJson.aspx",
                fileManagerJson: "Handle/KindEditorFileManagerJson.aspx",
                width: '668px',
                height: '375px',
                filterMode: false,
                allowFileManager: true
            });
            //添加保存
            function addSave() {
                $.ajaxFileUpload({
                    type: "POST",
                    fileElementId: 'add_upload',
                    dataType: 'json',
                    url: "Handle/Project/Add.aspx",
                    data: $('#add_form').serializeObject(),
                    success: function (msg) {
                        $.messager.show({
                            title: '提示',
                            msg: msg.message,
                            timeout: 5000,
                            showType: 'fade'
                        });
                        if (msg.state) {
                            $('#add_form')[0].reset();
                            addContent.html('');
                            addContentEn.html('');
                            $("#table_list").datagrid("reload");
                        }
                    },
                    error: function () {
                        $.messager.show({
                            title: '提示',
                            msg: '保存失败！',
                            timeout: 5000,
                            showType: 'fade'
                        });
                    }
                });
            }
            //编辑保存
            function editSave() {
                $.ajaxFileUpload({
                    type: "POST",
                    fileElementId: 'edit_upload',
                    dataType: 'json',
                    url: "Handle/Project/Edit.aspx",
                    data: $('#edit_form').serializeObject(),
                    success: function (msg) {
                        $.messager.show({
                            title: '提示',
                            msg: msg.message,
                            timeout: 5000,
                            showType: 'fade'
                        });
                        if (msg.state) {
                            $("#table_list").datagrid("reload");
                        }
                    },
                    error: function () {
                        $.messager.show({
                            title: '提示',
                            msg: '保存失败！',
                            timeout: 5000,
                            showType: 'fade'
                        });
                    }
                });
            }
        });
        //获取项目案例详细
        function edit(id) {
            $('#edit_form').form('load', 'Handle/Project/GetDetailJson.aspx?id=' + id);
        }
        function del(id) {
            $.messager.confirm("提示", "确认删除?", function (b) {
                if (b) {
                    $.ajax({
                        type: "POST",
                        url: "Handle/Project/Delete.aspx",
                        data: { id: id },
                        success: function (msg) {
                            $.messager.show({
                                title: '提示',
                                msg: msg.message,
                                timeout: 5000,
                                showType: 'fade'
                            });
                            if (msg.state)
                                $("#table_list").datagrid("reload");
                        },
                        error: function () {
                            $.messager.show({
                                title: '提示',
                                msg: '删除失败！',
                                timeout: 5000,
                                showType: 'fade'
                            });
                        }
                    });
                }
            });
        }
        function add() {
            $('#add').dialog("open");
        }
    </script>
</asp:Content>
